use serde::{Deserialize, Serialize};

use crate::models::models::commands::basic_command_setting::BasicCommandSetting;

/// 服务商定义
#[derive(Debug, Deserialize, Clone, Default, Serialize)]
pub(crate) enum Service {
    // 阿里云
    #[default]
    AliYun,
    // 腾讯云
    Tencent,
}

#[derive(Debug, Deserialize, Clone, Default, Serialize)]
pub(crate) enum AliYunModel {
    QWenTurbo,
    QWenPlus,
    #[default]
    QWenMax,
    QWen18BChat,
    QWen7BChat,
    QWen14BChat,
    QWen72BChat,
    LLaMa27B,
    LLaMa213B,
}

impl AliYunModel {
    pub fn to_string(&self) -> String {
        match self {
            Self::QWenTurbo => "qwen-turbo".to_string(),
            Self::QWenPlus => "qwen-plus".to_string(),
            Self::QWenMax => "qwen-max".to_string(),
            AliYunModel::QWen18BChat => "qwen-1.8b-chat".to_string(),
            AliYunModel::QWen7BChat => "qwen-7b-chat".to_string(),
            AliYunModel::QWen14BChat => "qwen-14b-chat".to_string(),
            AliYunModel::QWen72BChat => "qwen-72b-chat".to_string(),
            AliYunModel::LLaMa27B => "llama2-7b-chat-v2".to_string(),
            AliYunModel::LLaMa213B => "llama2-13b-chat-v2".to_string(),
        }
    }
}

#[derive(Debug, Deserialize, Clone, Default, Serialize)]
pub(crate) struct AliYunApiConfig {
    // 使用的模型
    pub(crate) model: AliYunModel,
    // API访问Token
    pub(crate) token: String,
    // 是否启用互联网搜索
    pub(crate) enable_search: bool,
}

#[derive(Debug, Default, Clone, Deserialize, Serialize)]
pub(crate) struct CommandAiConfig {
    // 基本命令设置
    #[serde(default)]
    pub(crate) basic_command_setting: BasicCommandSetting,
    // 服务商类型
    #[serde(default)]
    pub(crate) service: Service,
    // 阿里云API配置
    pub(crate) ali_yun_api_config: Option<AliYunApiConfig>,
    // 是否携带上下文
    #[serde(default)]
    // 携带的上下文数量
    pub(crate) post_context: bool,
    // 携带的上下文数量
    #[serde(default)]
    pub(crate) post_context_cnt: usize,
}